package com.springdoor.wx.api.controller;

import com.springdoor.wx.core.domain.AjaxResult;
import com.springdoor.wx.core.domain.entity.LoginBody;
import com.springdoor.wx.api.service.LoginService;
import com.springdoor.wx.utils.string.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class LoginController {

    @Autowired
    private LoginService loginService;

    @PostMapping("login")
    public AjaxResult login(@RequestBody LoginBody loginBody) {
        return loginService.login(loginBody.getJsCode());
    }

    @RequestMapping("verify-token")
    public AjaxResult verifyToken() {
        return AjaxResult.success();
    }

    @PostMapping("refresh-token")
    public AjaxResult loginByOpenid(@RequestBody LoginBody loginBody) {
        return loginService.loginByOpenid(loginBody.getOpenid());
    }
}
